package com.hellobike.haxing.modules.order.mapper;

import java.math.BigDecimal;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.order.entity.OrderRefund;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 订单退款记录
 * @Author: haxing-boot
 * @Date:   2020-02-08
 * @Version: V1.0
 */
public interface OrderRefundMapper extends BaseMapper<OrderRefund> {
    /**
     * 查询退款记录
     * @param page
     * @param queryWrapper
     * @return
     */
    IPage<OrderRefund> queryPage(Page<OrderRefund> page,@Param(Constants.WRAPPER) QueryWrapper<OrderRefund> queryWrapper);

    /**
     * 退款成功记录
     * @param orderId
     * @return
     */
    @Select("select sum(t.refund_amount) from  t_order_refund t where  t.refund_status in (20,21) and t.order_id =#{orderId}")
    BigDecimal getSumRefundSuccess(Long orderId);
}
